home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume14 / mxgdb / part08 < prev    next >
Encoding:
Text File  |  1991-10-08  |  40.2 KB  |  1,218 lines

  1. Path: uunet!sun-barr!cronkite.Central.Sun.COM!newstop!exodus!bullet.ma30.bull.com
  2. From: jtsillas@bullet.ma30.bull.com (Jim Tsillas)
  3. Newsgroups: comp.sources.x
  4. Subject: v14i076: mxgdb -- motif version of xxgdb, Part08/10
  5. Message-ID: <21237@exodus.Eng.Sun.COM>
  6. Date: 9 Oct 91 01:21:05 GMT
  7. References: <csx-14i069-mxgdb@uunet.UU.NET>
  8. Sender: news@exodus.Eng.Sun.COM
  9. Lines: 1206
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: jtsillas@bullet.ma30.bull.com (Jim Tsillas)
  13. Posting-number: Volume 14, Issue 76
  14. Archive-name: mxgdb/part08
  15.  
  16.  
  17. ---- Cut Here and feed the following to sh ----
  18. #!/bin/sh
  19. # this is mxgdb.08 (part 8 of a multipart archive)
  20. # do not concatenate these parts, unpack them in order with /bin/sh
  21. # file mxgdb/regex.c continued
  22. #
  23. if test ! -r _shar_seq_.tmp; then
  24.     echo 'Please unpack part 1 first!'
  25.     exit 1
  26. fi
  27. (read Scheck
  28.  if test "$Scheck" != 8; then
  29.     echo Please unpack part "$Scheck" next!
  30.     exit 1
  31.  else
  32.     exit 0
  33.  fi
  34. ) < _shar_seq_.tmp || exit 1
  35. if test ! -f _shar_wnt_.tmp; then
  36.     echo 'x - still skipping mxgdb/regex.c'
  37. else
  38. echo 'x - continuing file mxgdb/regex.c'
  39. sed 's/^X//' << 'SHAR_EOF' >> 'mxgdb/regex.c' &&
  40. X      if (d == string1  /* Points to first char */
  41. X          || SYNTAX (((unsigned char *)d)[-1]) != Sword) 
  42. X        break;
  43. X      goto fail;
  44. X
  45. X    case wordend:
  46. X      if (d == string1  /* Points to first char */
  47. X          || SYNTAX (((unsigned char *)d)[-1]) != 
  48. X          Sword)  /* prev char not letter */
  49. X        goto fail;
  50. X      if (d == end2  /* Points to end */
  51. X          || (d == end1 && size2 == 0) /* Points to end */
  52. X          || SYNTAX (d == end1 ? *(unsigned char *)string2 : 
  53. X             *(unsigned char *)d) != 
  54. X          Sword) /* Next char not a letter */
  55. X        break;
  56. X      goto fail;
  57. X
  58. #ifdef emacs
  59. X    case before_dot:
  60. X      if (((d - string2 <= (unsigned) size2)
  61. X           ? d - (char *) bf_p2 : d - (char *) bf_p1)
  62. X          <= point)
  63. X        goto fail;
  64. X      break;
  65. X
  66. X    case at_dot:
  67. X      if (((d - string2 <= (unsigned) size2)
  68. X           ? d - (char *) bf_p2 : d - (char *) bf_p1)
  69. X          == point)
  70. X        goto fail;
  71. X      break;
  72. X
  73. X    case after_dot:
  74. X      if (((d - string2 <= (unsigned) size2)
  75. X           ? d - (char *) bf_p2 : d - (char *) bf_p1)
  76. X          >= point)
  77. X        goto fail;
  78. X      break;
  79. X
  80. X    case wordchar:
  81. X      mcnt = (int) Sword;
  82. X      goto matchsyntax;
  83. X
  84. X    case syntaxspec:
  85. X      mcnt = *p++;
  86. X    matchsyntax:
  87. X      PREFETCH;
  88. X      if (SYNTAX (*(unsigned char *)d++) != (enum syntaxcode) mcnt) goto fail;
  89. X      break;
  90. X      
  91. X    case notwordchar:
  92. X      mcnt = (int) Sword;
  93. X      goto matchnotsyntax;
  94. X
  95. X    case notsyntaxspec:
  96. X      mcnt = *p++;
  97. X    matchnotsyntax:
  98. X      PREFETCH;
  99. X      if (SYNTAX (*(unsigned char *)d++) == (enum syntaxcode) mcnt) goto fail;
  100. X      break;
  101. #else
  102. X    case wordchar:
  103. X      PREFETCH;
  104. X      if (SYNTAX (*(unsigned char *)d++) == 0) goto fail;
  105. X      break;
  106. X      
  107. X    case notwordchar:
  108. X      PREFETCH;
  109. X      if (SYNTAX (*(unsigned char *)d++) != 0) goto fail;
  110. X      break;
  111. #endif not emacs
  112. X
  113. X    case begbuf:
  114. X      if (d == string1)    /* Note, d cannot equal string2 */
  115. X        break;        /* unless string1 == string2.  */
  116. X      goto fail;
  117. X
  118. X    case endbuf:
  119. X      if (d == end2 || (d == end1 && size2 == 0))
  120. X        break;
  121. X      goto fail;
  122. X
  123. X    case exactn:
  124. X      /* Match the next few pattern characters exactly.
  125. X         mcnt is how many characters to match. */
  126. X      mcnt = *p++;
  127. X      if (translate)
  128. X        {
  129. X          do
  130. X        {
  131. X          PREFETCH;
  132. X          if (translate[*(unsigned char *)d++] != *p++) goto fail;
  133. X        }
  134. X          while (--mcnt);
  135. X        }
  136. X      else
  137. X        {
  138. X          do
  139. X        {
  140. X          PREFETCH;
  141. X          if (*d++ != *p++) goto fail;
  142. X        }
  143. X          while (--mcnt);
  144. X        }
  145. X      break;
  146. X    }
  147. X      continue;    /* Successfully matched one pattern command; keep matching */
  148. X
  149. X      /* Jump here if any matching operation fails. */
  150. X    fail:
  151. X      if (stackp != stackb)
  152. X    /* A restart point is known.  Restart there and pop it. */
  153. X    {
  154. X      if (!stackp[-2])
  155. X        {   /* If innermost failure point is dormant, flush it and keep looking */
  156. X          stackp -= 2;
  157. X          goto fail;
  158. X        }
  159. X      d = *--stackp;
  160. X      p = *--stackp;
  161. X      if (d >= string1 && d <= end1)
  162. X        dend = end_match_1;
  163. X    }
  164. X      else break;   /* Matching at this starting point really fails! */
  165. X    }
  166. X  return -1;         /* Failure to match */
  167. }
  168. X
  169. int
  170. bcmp_translate (s1, s2, len, translate)
  171. X     unsigned char *s1, *s2;
  172. X     register int len;
  173. X     unsigned char *translate;
  174. {
  175. X  register unsigned char *p1 = s1, *p2 = s2;
  176. X  while (len)
  177. X    {
  178. X      if (translate [*p1++] != translate [*p2++]) return 1;
  179. X      len--;
  180. X    }
  181. X  return 0;
  182. }
  183. X
  184. /* Entry points compatible with bsd4.2 regex library */
  185. X
  186. #ifndef emacs
  187. X
  188. static struct re_pattern_buffer re_comp_buf;
  189. X
  190. char *
  191. re_comp (s)
  192. X     char *s;
  193. {
  194. X  if (!s)
  195. X    {
  196. X      if (!re_comp_buf.buffer)
  197. X    return "No previous regular expression";
  198. X      return 0;
  199. X    }
  200. X
  201. X  if (!re_comp_buf.buffer)
  202. X    {
  203. X      if (!(re_comp_buf.buffer = (char *) malloc (200)))
  204. X    return "Memory exhausted";
  205. X      re_comp_buf.allocated = 200;
  206. X      if (!(re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH)))
  207. X    return "Memory exhausted";
  208. X    }
  209. X  return re_compile_pattern (s, strlen (s), &re_comp_buf);
  210. }
  211. X
  212. int
  213. re_exec (s)
  214. X     char *s;
  215. {
  216. X  int len = strlen (s);
  217. X  return 0 <= re_search (&re_comp_buf, s, len, 0, len, 0);
  218. }
  219. X
  220. #endif /* emacs */
  221. X
  222. #ifdef test
  223. X
  224. #include <stdio.h>
  225. X
  226. /* Indexed by a character, gives the upper case equivalent of the character */
  227. X
  228. static char upcase[0400] = 
  229. X  { 000, 001, 002, 003, 004, 005, 006, 007,
  230. X    010, 011, 012, 013, 014, 015, 016, 017,
  231. X    020, 021, 022, 023, 024, 025, 026, 027,
  232. X    030, 031, 032, 033, 034, 035, 036, 037,
  233. X    040, 041, 042, 043, 044, 045, 046, 047,
  234. X    050, 051, 052, 053, 054, 055, 056, 057,
  235. X    060, 061, 062, 063, 064, 065, 066, 067,
  236. X    070, 071, 072, 073, 074, 075, 076, 077,
  237. X    0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107,
  238. X    0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,
  239. X    0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127,
  240. X    0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137,
  241. X    0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107,
  242. X    0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,
  243. X    0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127,
  244. X    0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177,
  245. X    0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207,
  246. X    0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217,
  247. X    0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227,
  248. X    0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237,
  249. X    0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247,
  250. X    0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257,
  251. X    0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,
  252. X    0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,
  253. X    0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307,
  254. X    0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317,
  255. X    0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327,
  256. X    0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,
  257. X    0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,
  258. X    0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357,
  259. X    0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,
  260. X    0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377
  261. X  };
  262. X
  263. main ()
  264. {
  265. X  char pat[80];
  266. X  struct re_pattern_buffer buf;
  267. X  int i;
  268. X  char c;
  269. X  char fastmap[(1 << BYTEWIDTH)];
  270. X
  271. X  buf.allocated = 40;
  272. X  buf.buffer = (char *) malloc (buf.allocated);
  273. X  buf.fastmap = fastmap;
  274. X  buf.translate = upcase;
  275. X
  276. X  while (1)
  277. X    {
  278. X      gets (pat);
  279. X
  280. X      if (*pat)
  281. X    {
  282. X          re_compile_pattern (pat, strlen(pat), &buf);
  283. X
  284. X      for (i = 0; i < buf.used; i++)
  285. X        printchar (buf.buffer[i]);
  286. X
  287. X      putchar ('\n');
  288. X
  289. X      printf ("%d allocated, %d used.\n", buf.allocated, buf.used);
  290. X
  291. X      re_compile_fastmap (&buf);
  292. X      printf ("Allowed by fastmap: ");
  293. X      for (i = 0; i < (1 << BYTEWIDTH); i++)
  294. X        if (fastmap[i]) printchar (i);
  295. X      putchar ('\n');
  296. X    }
  297. X
  298. X      gets (pat);    /* Now read the string to match against */
  299. X
  300. X      i = re_match (&buf, pat, strlen (pat), 0, 0);
  301. X      printf ("Match value %d.\n", i);
  302. X    }
  303. }
  304. X
  305. #ifdef NOTDEF
  306. print_buf (bufp)
  307. X     struct re_pattern_buffer *bufp;
  308. {
  309. X  int i;
  310. X
  311. X  printf ("buf is :\n----------------\n");
  312. X  for (i = 0; i < bufp->used; i++)
  313. X    printchar (bufp->buffer[i]);
  314. X  
  315. X  printf ("\n%d allocated, %d used.\n", bufp->allocated, bufp->used);
  316. X  
  317. X  printf ("Allowed by fastmap: ");
  318. X  for (i = 0; i < (1 << BYTEWIDTH); i++)
  319. X    if (bufp->fastmap[i])
  320. X      printchar (i);
  321. X  printf ("\nAllowed by translate: ");
  322. X  if (bufp->translate)
  323. X    for (i = 0; i < (1 << BYTEWIDTH); i++)
  324. X      if (bufp->translate[i])
  325. X    printchar (i);
  326. X  printf ("\nfastmap is%s accurate\n", bufp->fastmap_accurate ? "" : "n't");
  327. X  printf ("can %s be null\n----------", bufp->can_be_null ? "" : "not");
  328. }
  329. #endif
  330. X
  331. printchar (c)
  332. X     char c;
  333. {
  334. X  if (c < 041 || c >= 0177)
  335. X    {
  336. X      putchar ('\\');
  337. X      putchar (((c >> 6) & 3) + '0');
  338. X      putchar (((c >> 3) & 7) + '0');
  339. X      putchar ((c & 7) + '0');
  340. X    }
  341. X  else
  342. X    putchar (c);
  343. }
  344. X
  345. error (string)
  346. X     char *string;
  347. {
  348. X  puts (string);
  349. X  exit (1);
  350. }
  351. X
  352. #endif test
  353. SHAR_EOF
  354. echo 'File mxgdb/regex.c is complete' &&
  355. chmod 0644 mxgdb/regex.c ||
  356. echo 'restore of mxgdb/regex.c failed'
  357. Wc_c="`wc -c < 'mxgdb/regex.c'`"
  358. test 46422 -eq "$Wc_c" ||
  359.     echo 'mxgdb/regex.c: original size 46422, current size' "$Wc_c"
  360. rm -f _shar_wnt_.tmp
  361. fi
  362. # ============= mxgdb/regex.h ==============
  363. if test -f 'mxgdb/regex.h' -a X"$1" != X"-c"; then
  364.     echo 'x - skipping mxgdb/regex.h (File already exists)'
  365.     rm -f _shar_wnt_.tmp
  366. else
  367. > _shar_wnt_.tmp
  368. echo 'x - extracting mxgdb/regex.h (Text)'
  369. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/regex.h' &&
  370. /* $Id: regex.h,v 1.1.1.1 1991/05/16 21:42:41 jtsillas Exp $ */
  371. X
  372. /* Definitions for data structures callers pass the regex library.
  373. X   Copyright (C) 1985 Free Software Foundation, Inc.
  374. X
  375. X               NO WARRANTY
  376. X
  377. X  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  378. NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  379. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  380. RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  381. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  382. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  383. FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  384. AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  385. DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  386. CORRECTION.
  387. X
  388. X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  389. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  390. WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  391. LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  392. OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  393. USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  394. DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  395. A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  396. PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  397. DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  398. X
  399. X        GENERAL PUBLIC LICENSE TO COPY
  400. X
  401. X  1. You may copy and distribute verbatim copies of this source file
  402. as you receive it, in any medium, provided that you conspicuously and
  403. appropriately publish on each copy a valid copyright notice "Copyright
  404. (C) 1985 Free Software Foundation, Inc."; and include following the
  405. copyright notice a verbatim copy of the above disclaimer of warranty
  406. and of this License.  You may charge a distribution fee for the
  407. physical act of transferring a copy.
  408. X
  409. X  2. You may modify your copy or copies of this source file or
  410. any portion of it, and copy and distribute such modifications under
  411. the terms of Paragraph 1 above, provided that you also do the following:
  412. X
  413. X    a) cause the modified files to carry prominent notices stating
  414. X    that you changed the files and the date of any change; and
  415. X
  416. X    b) cause the whole of any work that you distribute or publish,
  417. X    that in whole or in part contains or is a derivative of this
  418. X    program or any part thereof, to be licensed at no charge to all
  419. X    third parties on terms identical to those contained in this
  420. X    License Agreement (except that you may choose to grant more extensive
  421. X    warranty protection to some or all third parties, at your option).
  422. X
  423. X    c) You may charge a distribution fee for the physical act of
  424. X    transferring a copy, and you may at your option offer warranty
  425. X    protection in exchange for a fee.
  426. X
  427. Mere aggregation of another unrelated program with this program (or its
  428. derivative) on a volume of a storage or distribution medium does not bring
  429. the other program under the scope of these terms.
  430. X
  431. X  3. You may copy and distribute this program (or a portion or derivative
  432. of it, under Paragraph 2) in object code or executable form under the terms
  433. of Paragraphs 1 and 2 above provided that you also do one of the following:
  434. X
  435. X    a) accompany it with the complete corresponding machine-readable
  436. X    source code, which must be distributed under the terms of
  437. X    Paragraphs 1 and 2 above; or,
  438. X
  439. X    b) accompany it with a written offer, valid for at least three
  440. X    years, to give any third party free (except for a nominal
  441. X    shipping charge) a complete machine-readable copy of the
  442. X    corresponding source code, to be distributed under the terms of
  443. X    Paragraphs 1 and 2 above; or,
  444. X
  445. X    c) accompany it with the information you received as to where the
  446. X    corresponding source code may be obtained.  (This alternative is
  447. X    allowed only for noncommercial distribution and only if you
  448. X    received the program in object code or executable form alone.)
  449. X
  450. For an executable file, complete source code means all the source code for
  451. all modules it contains; but, as a special exception, it need not include
  452. source code for modules which are standard libraries that accompany the
  453. operating system on which the executable file runs.
  454. X
  455. X  4. You may not copy, sublicense, distribute or transfer this program
  456. except as expressly provided under this License Agreement.  Any attempt
  457. otherwise to copy, sublicense, distribute or transfer this program is void and
  458. your rights to use the program under this License agreement shall be
  459. automatically terminated.  However, parties who have received computer
  460. software programs from you with this License Agreement will not have
  461. their licenses terminated so long as such parties remain in full compliance.
  462. X
  463. X  5. If you wish to incorporate parts of this program into other free
  464. programs whose distribution conditions are different, write to the Free
  465. Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  466. worked out a simple rule that can be stated here, but we will often permit
  467. this.  We will be guided by the two goals of preserving the free status of
  468. all derivatives of our free software and of promoting the sharing and reuse of
  469. software.
  470. X
  471. X
  472. In other words, you are welcome to use, share and improve this program.
  473. You are forbidden to forbid anyone else to use, share and improve
  474. what you give them.   Help stamp out software-hoarding!  */
  475. X
  476. X
  477. #ifndef RE_NREGS
  478. #define RE_NREGS 10
  479. #endif
  480. X
  481. /* This data structure is used to represent a compiled pattern. */
  482. X
  483. struct re_pattern_buffer
  484. X  {
  485. X    char *buffer;    /* Space holding the compiled pattern commands. */
  486. X    int allocated;    /* Size of space that  buffer  points to */
  487. X    int used;        /* Length of portion of buffer actually occupied */
  488. X    char *fastmap;    /* Pointer to fastmap, if any, or zero if none. */
  489. X            /* re_search uses the fastmap, if there is one,
  490. X               to skip quickly over totally implausible characters */
  491. X    char *translate;    /* Translate table to apply to all characters 
  492. X                           before comparing.
  493. X               Or zero for no translation.
  494. X               The translation is applied to a pattern when it is compiled
  495. X               and to data when it is matched. */
  496. X    char fastmap_accurate;
  497. X            /* Set to zero when a new pattern is stored,
  498. X               set to one when the fastmap is updated from it. */
  499. X    char can_be_null;   /* Set to one by compiling fastmap
  500. X               if this pattern might match the null string.
  501. X               It does not necessarily match the null string
  502. X               in that case, but if this is zero, it cannot.
  503. X               2 as value means can match null string
  504. X               but at end of range or before a character
  505. X               listed in the fastmap.  */
  506. X  };
  507. X
  508. /* Structure to store "register" contents data in.
  509. X
  510. X   Pass the address of such a structure as an argument to re_match, etc.,
  511. X   if you want this information back.
  512. X
  513. X   start[i] and end[i] record the string matched by \( ... \) grouping i,
  514. X   for i from 1 to RE_NREGS - 1.
  515. X   start[0] and end[0] record the entire string matched. */
  516. X
  517. struct re_registers
  518. X  {
  519. X    int start[RE_NREGS];
  520. X    int end[RE_NREGS];
  521. X  };
  522. X
  523. /* These are the command codes that appear in compiled regular expressions, 
  524. X  one per byte.
  525. X  Some command codes are followed by argument bytes.
  526. X  A command code can specify any interpretation whatever for its arguments.
  527. X  Zero-bytes may appear in the compiled regular expression. */
  528. X
  529. enum regexpcode
  530. X  {
  531. X    unused,
  532. X    exactn,    /* followed by one byte giving n, and then by n literal bytes */
  533. X    begline,   /* fails unless at beginning of line */
  534. X    endline,   /* fails unless at end of line */
  535. X    jump,     /* followed by two bytes giving relative address to jump to */
  536. X    on_failure_jump,     /* followed by two bytes giving relative address of place
  537. X                    to resume at in case of failure. */
  538. X    finalize_jump,     /* Throw away latest failure point and then 
  539. X                jump to address. */
  540. X    maybe_finalize_jump, /* Like jump but finalize if safe to do so.
  541. X                This is used to jump back to the beginning
  542. X                of a repeat.  If the command that follows
  543. X                this jump is clearly incompatible with the
  544. X                one at the beginning of the repeat, such that
  545. X                we can be sure that there is no use backtracking
  546. X                out of repetitions already completed,
  547. X                then we finalize. */
  548. X    dummy_failure_jump,  /* jump, and push a dummy failure point.
  549. X                This failure point will be thrown away
  550. X                if an attempt is made to use it for a failure.
  551. X                A + construct makes this before the first repeat.  */
  552. X    anychar,     /* matches any one character */
  553. X    charset,     /* matches any one char belonging to specified set.
  554. X            First following byte is # bitmap bytes.
  555. X            Then come bytes for a bit-map saying which chars are in.
  556. X            Bits in each byte are ordered low-bit-first.
  557. X            A character is in the set if its bit is 1.
  558. X            A character too large to have a bit in the map
  559. X            is automatically not in the set */
  560. X    charset_not, /* similar but match any character that is NOT one 
  561. X                    of those specified */
  562. X    start_memory, /* starts remembering the text that is matched
  563. X            and stores it in a memory register.
  564. X            followed by one byte containing the register number.
  565. X            Register numbers must be in the range 0 through NREGS. */
  566. X    stop_memory, /* stops remembering the text that is matched
  567. X            and stores it in a memory register.
  568. X            followed by one byte containing the register number.
  569. X            Register numbers must be in the range 0 through NREGS. */
  570. X    duplicate,    /* match a duplicate of something remembered.
  571. X            Followed by one byte containing the index of the memory register. */
  572. X    before_dot,     /* Succeeds if before dot */
  573. X    at_dot,     /* Succeeds if at dot */
  574. X    after_dot,     /* Succeeds if after dot */
  575. X    begbuf,      /* Succeeds if at beginning of buffer */
  576. X    endbuf,      /* Succeeds if at end of buffer */
  577. X    wordchar,    /* Matches any word-constituent character */
  578. X    notwordchar, /* Matches any char that is not a word-constituent */
  579. X    wordbeg,     /* Succeeds if at word beginning */
  580. X    wordend,     /* Succeeds if at word end */
  581. X    wordbound,   /* Succeeds if at a word boundary */
  582. X    notwordbound, /* Succeeds if not at a word boundary */
  583. X    syntaxspec,  /* Matches any character whose syntax is specified.
  584. X            followed by a byte which contains a syntax code, Sword 
  585. X                or such like */
  586. X    notsyntaxspec /* Matches any character whose syntax differs from 
  587. X                     the specified. */
  588. X  };
  589. X
  590. extern char *re_compile_pattern ();
  591. /* Is this really advertised? */
  592. extern void re_compile_fastmap ();
  593. extern int re_search (), re_search_2 ();
  594. extern int re_match (), re_match_2 ();
  595. X
  596. /* 4.2 bsd compatibility (yuck) */
  597. extern char *re_comp ();
  598. extern int re_exec ();
  599. X
  600. #ifdef SYNTAX_TABLE
  601. extern char *re_syntax_table;
  602. #endif
  603. SHAR_EOF
  604. chmod 0644 mxgdb/regex.h ||
  605. echo 'restore of mxgdb/regex.h failed'
  606. Wc_c="`wc -c < 'mxgdb/regex.h'`"
  607. test 10897 -eq "$Wc_c" ||
  608.     echo 'mxgdb/regex.h: original size 10897, current size' "$Wc_c"
  609. rm -f _shar_wnt_.tmp
  610. fi
  611. # ============= mxgdb/dialog.c ==============
  612. if test -f 'mxgdb/dialog.c' -a X"$1" != X"-c"; then
  613.     echo 'x - skipping mxgdb/dialog.c (File already exists)'
  614.     rm -f _shar_wnt_.tmp
  615. else
  616. > _shar_wnt_.tmp
  617. echo 'x - extracting mxgdb/dialog.c (Text)'
  618. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/dialog.c' &&
  619. static char rcsid[] = "$Id: dialog.c,v 1.5 1991/08/14 17:51:46 jtsillas Exp $";
  620. X
  621. /*****************************************************************************
  622. X *
  623. X *  xdbx - X Window System interface to the dbx debugger
  624. X *
  625. X *  Copyright 1989 The University of Texas at Austin
  626. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  627. X *
  628. X *  Permission to use, copy, modify, and distribute this software and its
  629. X *  documentation for any purpose and without fee is hereby granted,
  630. X *  provided that the above copyright notice appear in all copies and that
  631. X *  both that copyright notice and this permission notice appear in
  632. X *  supporting documentation, and that the name of The University of Texas
  633. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  634. X *  used in advertising or publicity pertaining to distribution of
  635. X *  the software without specific, written prior permission.  The
  636. X *  University of Texas and MCC makes no representations about the 
  637. X *  suitability of this software for any purpose.  It is provided "as is" 
  638. X *  without express or implied warranty.
  639. X *
  640. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  641. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  642. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  643. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  644. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  645. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  646. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  647. X *
  648. X *  Author:      Po Cheung
  649. X *  Created:       March 10, 1989
  650. X * 
  651. X *****************************************************************************
  652. X * 
  653. X *  xxgdb - X Window System interface to the gdb debugger
  654. X *  
  655. X *     Copyright 1990 Thomson Consumer Electronics, Inc.
  656. X *  
  657. X *  Permission to use, copy, modify, and distribute this software and its
  658. X *  documentation for any purpose and without fee is hereby granted,
  659. X *  provided that the above copyright notice appear in all copies and that
  660. X *  both that copyright notice and this permission notice appear in
  661. X *  supporting documentation, and that the name of Thomson Consumer
  662. X *  Electronics (TCE) not be used in advertising or publicity pertaining
  663. X *  to distribution of the software without specific, written prior
  664. X *  permission.  TCE makes no representations about the suitability of
  665. X *  this software for any purpose.  It is provided "as is" without express
  666. X *  or implied warranty.
  667. X *
  668. X *  TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  669. X *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  670. X *  SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  671. X *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  672. X *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  673. X *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  674. X *  SOFTWARE.
  675. X *
  676. X *  Adaptation to GDB:  Pierre Willard
  677. X *  XXGDB Created:       December, 1990
  678. X *
  679. X *****************************************************************************/
  680. X
  681. /*  dialog.c
  682. X *
  683. X *    Create the dialogue window where the user enter dbx commands, and
  684. X *    provide action procs to make a text widget behave like a terminal.
  685. X *
  686. X *    InsertSpace():    Prevent user from deleting past the prompt (action proc
  687. X *            for DELETE or BACKSPACE).
  688. X *    Dispatch():    Send an input command line to dbx. (action proc for CR).
  689. X *    SigInt():        Send SIGINT to dbx (action proc for Ctrl-C).
  690. X *    SigEof():        Send an EOF signal to dbx (action proc for Ctrl-D).
  691. X *    SigQuit():    Send SIGQUIT to dbx (action proc for Ctrl-\).
  692. X *    CreateDialogWindow(): Create dialog window and install action table.
  693. X *    AppendDialogText():       Append string to dialog window.
  694. X */
  695. X
  696. #include <signal.h>
  697. #include "global.h"
  698. #include <Xm/Xm.h>
  699. #include <Xm/Text.h>
  700. X
  701. Widget    dialogWindow;            /* text window as a dbx terminal */
  702. Boolean FalseSignal = FALSE;        /* set to TRUE before self-generated
  703. X                       interrupt/quit signals */
  704. static XmTextPosition  StartPos;          /* starting position of input text */
  705. X
  706. X
  707. /*  This procedure prevents the user from deleting past the prompt, or
  708. X *  any text appended by AppendDialogText() to the dialog window.
  709. X *  It checks the last position of text, if it matches StartPos, set
  710. X *  by AppendDialogText(), it inserts a space so that delete-previous-
  711. X *  character() can only delete the space character.
  712. X */
  713. /* ARGSUSED */
  714. static void InsertSpace(w, event, params, num_params)
  715. X    Widget w;
  716. X    XEvent *event;
  717. X    String *params;
  718. X    Cardinal *num_params;
  719. {
  720. X  XmTextPosition lastPos;
  721. X
  722. X  if (XmTextGetInsertionPosition(w) <= StartPos) {
  723. X    lastPos = TextGetLastPos(w);
  724. X    if (lastPos == StartPos) 
  725. X      XmTextInsert(w, lastPos, " ");
  726. X    }
  727. }
  728. X
  729. static void InsertSelection(w, event, params, num_params)
  730. X    Widget w;
  731. X    XEvent *event;
  732. X    String *params;
  733. X    Cardinal *num_params;
  734. {
  735. X  XmTextSetInsertionPosition(w, XmTextGetLastPosition(w));
  736. }
  737. X
  738. X
  739. /*  Dispatch() is invoked on every <CR>.
  740. X *  It collects text from the dialog window and sends it to dbx.
  741. X *  If the string is a command to dbx (Prompt would be TRUE),
  742. X *  it is stored in the global variable, Command.
  743. X */
  744. /* ARGSUSED */
  745. static void Dispatch(w, event, params, num_params)
  746. X    Widget w;
  747. X    XEvent *event;
  748. X    String *params;
  749. X    Cardinal *num_params; 
  750. {
  751. X  char *DialogText;
  752. X    /* 
  753. X    For GDB, '\n' means exec previous command again.
  754. X    default command is space+CR, so that we never send
  755. X    CR to gdb (the repeat is managed here)
  756. X    */
  757. X    static char gdb_command[LINESIZ] = " \n";
  758. X    char s[LINESIZ];
  759. X
  760. X  DialogText = XmTextGetString(dialogWindow);
  761. X  strcpy(s, DialogText + StartPos);
  762. X    /* (PW)18DEC90 : bug xdbx : without the following line,
  763. X    xdbx sends several times the same lines when Prompt is false */
  764. X    StartPos = TextGetLastPos(dialogWindow);
  765. X
  766. X    if (Prompt) {
  767. X    if (gdb_source_command(s,FALSE))    /* filter source command (& do not display source command) */
  768. X        {
  769. X        strcpy(gdb_command," \n");    /* do not execute anything if next command is '\n' */
  770. X        return;
  771. X        }
  772. X    /* When we send \n to gdb, it executes the last command,
  773. X    so better tell xxgdb what gdb is doing */
  774. X    if (strcmp(s, "\n"))
  775. X        strcpy(gdb_command,s);
  776. X    else
  777. X        strcpy(s,gdb_command);
  778. X    send_command(s);
  779. X    }
  780. X    else {
  781. X        write_dbx(s);
  782. X    }
  783. X  XtFree(DialogText);
  784. }
  785. X
  786. X
  787. /*  Sends an interrupt signal, SIGINT, to dbx.
  788. X *  Simulates the action of the INTR character (ctrl-C).
  789. X */
  790. /* ARGSUSED */
  791. static void SigInt(w, event, params, num_params)
  792. X    Widget w;
  793. X    XEvent *event;
  794. X    String *params;
  795. X    Cardinal *num_params;
  796. {
  797. X  FalseSignal = TRUE;
  798. #if defined(SYSV) && !defined(SUNOS4)
  799. X  kill(dbxpid, SIGINT);
  800. #else
  801. X  write_dbx("\03");
  802. #endif
  803. }
  804. X
  805. X
  806. /*  Sends an EOF signal to dbx. (ctrl-D) */
  807. /* ARGSUSED */
  808. static void SigEof(w, event, params, num_params)
  809. X    Widget w;
  810. X    XEvent *event;
  811. X    String *params;
  812. X    Cardinal *num_params;
  813. {
  814. X    write_dbx("\04");
  815. }
  816. X
  817. X
  818. /*  Sends a QUIT signal, SIGQUIT, to dbx. 
  819. X *  Simulates the action of the QUIT character (ctrl-\) 
  820. X */
  821. /* ARGSUSED */
  822. static void SigQuit(w, event, params, num_params)
  823. X    Widget w;
  824. X    XEvent *event;
  825. X    String *params;
  826. X    Cardinal *num_params;
  827. {
  828. X  FalseSignal = TRUE;
  829. #if defined(SYSV) && !defined(SUNOS4)
  830. X  kill(dbxpid, SIGQUIT);
  831. #else
  832. X  write_dbx("\034");
  833. #endif
  834. }
  835. X
  836. X
  837. /* 
  838. X *  Dialog window has its own set of translations for editing.
  839. X *  Special action procedures for keys Delete/Backspace, Carriage Return,
  840. X *  Ctrl-U, Ctrl-C, Ctrl-D, Ctrl-\, and word selection.
  841. X */
  842. void CreateDialogWindow(parent)
  843. Widget parent;
  844. {
  845. X    Arg     args[MAXARGS];
  846. X    Cardinal     n;
  847. X
  848. X    static XtActionsRec dialog_actions[] = {
  849. X    {"SigInt",     (XtActionProc) SigInt},
  850. X    {"SigEof",     (XtActionProc) SigEof},
  851. X    {"SigQuit",     (XtActionProc) SigQuit},
  852. X    {"InsertSpace", (XtActionProc) InsertSpace},
  853. X    {"InsertSelection", (XtActionProc) InsertSelection},
  854. X    {"Dispatch",     (XtActionProc) Dispatch},
  855. X        {NULL, NULL}
  856. X    };
  857. X
  858. X    static Arg dialogargs[] = {
  859. X      { XmNeditMode, XmMULTI_LINE_EDIT },
  860. X      { XmNautoShowCursorPosition, True },
  861. X      { XmNscrollingPolicy, XmAUTOMATIC },
  862. X      { XmNscrollLeftSide, True },
  863. X      { XmNwordWrap, True },
  864. X      { XmNhighlightOnEnter, True },
  865. X    };
  866. X
  867. X    dialogWindow = XmCreateScrolledText(parent, "dialogWindow",
  868. X                                          dialogargs, 6);
  869. X    XtManageChild(dialogWindow);
  870. X
  871. X    XtAppAddActions(app_context, dialog_actions, XtNumber(dialog_actions));
  872. }
  873. X
  874. static void TextSetLastPos(w, lastPos)
  875. Widget w;
  876. XXmTextPosition lastPos;
  877. {
  878. X    Arg         args[MAXARGS];
  879. X    XtSetArg(args[0], XmNcursorPosition, lastPos);
  880. X    XtSetValues(w, args, 1);
  881. }
  882. void AppendDialogText(s)
  883. X    char   *s;
  884. {
  885. X    XmTextPosition     i, lastPos;
  886. X    XmTextBlockRec        textblock, nullblock;
  887. X    Arg         args[MAXARGS];
  888. X    Cardinal         n;
  889. X
  890. X    if (!s || !strcmp(s, "")) return;
  891. X
  892. X    textblock.length   = strlen(s);
  893. X    textblock.ptr      = s;
  894. X
  895. X    lastPos = XmTextGetLastPosition(dialogWindow);
  896. X
  897. X    XmTextInsert(dialogWindow, lastPos,
  898. X          textblock.ptr);
  899. X    StartPos = TextGetLastPos(dialogWindow);
  900. X    XmTextSetInsertionPosition(dialogWindow, 
  901. X                   XmTextGetLastPosition(dialogWindow));
  902. }
  903. SHAR_EOF
  904. chmod 0644 mxgdb/dialog.c ||
  905. echo 'restore of mxgdb/dialog.c failed'
  906. Wc_c="`wc -c < 'mxgdb/dialog.c'`"
  907. test 9190 -eq "$Wc_c" ||
  908.     echo 'mxgdb/dialog.c: original size 9190, current size' "$Wc_c"
  909. rm -f _shar_wnt_.tmp
  910. fi
  911. # ============= mxgdb/utils.c ==============
  912. if test -f 'mxgdb/utils.c' -a X"$1" != X"-c"; then
  913.     echo 'x - skipping mxgdb/utils.c (File already exists)'
  914.     rm -f _shar_wnt_.tmp
  915. else
  916. > _shar_wnt_.tmp
  917. echo 'x - extracting mxgdb/utils.c (Text)'
  918. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/utils.c' &&
  919. static char rcsid[] = "$Id: utils.c,v 1.1.1.1 1991/05/16 21:42:53 jtsillas Exp $";
  920. X
  921. /*****************************************************************************
  922. X *
  923. X *  xdbx - X Window System interface to the dbx debugger
  924. X *
  925. X *  Copyright 1989 The University of Texas at Austin
  926. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  927. X *
  928. X *  Permission to use, copy, modify, and distribute this software and its
  929. X *  documentation for any purpose and without fee is hereby granted,
  930. X *  provided that the above copyright notice appear in all copies and that
  931. X *  both that copyright notice and this permission notice appear in
  932. X *  supporting documentation, and that the name of The University of Texas
  933. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  934. X *  used in advertising or publicity pertaining to distribution of
  935. X *  the software without specific, written prior permission.  The
  936. X *  University of Texas and MCC makes no representations about the 
  937. X *  suitability of this software for any purpose.  It is provided "as is" 
  938. X *  without express or implied warranty.
  939. X *
  940. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  941. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  942. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  943. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  944. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  945. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  946. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  947. X *
  948. X *  Author:      Po Cheung
  949. X *  Created:       March 10, 1989
  950. X *
  951. X *****************************************************************************/
  952. X
  953. /*  utils.c
  954. X *
  955. X *    Contain common routines used by other functions.
  956. X *
  957. X *    TextGetLastPos():        Get the last insertion position of text.
  958. X *    TextPositionToLine():     Return text position give a line number.
  959. X *    LineToStopNo():        Return the stop number given a line number.
  960. X *    DisableWindowResize():    Fix the size of a window inside vpane.
  961. X *    bell():            Ring the bell.
  962. X *    concat():            Concatenate two strings together
  963. X */
  964. X
  965. #include "global.h"
  966. #include <Xm/Xm.h>
  967. #include <Xm/Text.h>
  968. X
  969. X
  970. XXmTextPosition TextGetLastPos(w)
  971. X    Widget w;
  972. {
  973. X    Arg    args[MAXARGS];
  974. X    XmTextPosition cursorPos;
  975. X
  976. X    XtSetArg(args[0], XmNcursorPosition, &cursorPos);
  977. X    XtGetValues(w, args, 1);
  978. X    return(cursorPos);    
  979. }
  980. X
  981. /*
  982. X * Get the line number where the caret is.
  983. X */
  984. int TextPositionToLine(pos)
  985. XXmTextPosition pos;
  986. {
  987. X    int line;
  988. X
  989. X    if (displayedFile) {
  990. X    if (pos >= displayedFile->linepos[displayedFile->topline]) {
  991. X        for (line = displayedFile->topline;
  992. X         pos > displayedFile->linepos[line]; line++);
  993. X        return (pos == displayedFile->linepos[line] ? line : line-1);
  994. X    }
  995. X    else {
  996. X        for (line = 1; pos > displayedFile->linepos[line]; line++);
  997. X        return (pos == displayedFile->linepos[line] ? line : line-1);
  998. X    }
  999. X    }
  1000. X    else
  1001. X        return 0;
  1002. }
  1003. X
  1004. /*
  1005. X *  Return the stop number associated with a given line number.
  1006. X *  Return 0 if stop number not found.
  1007. X */
  1008. int LineToStop_no(line)
  1009. int line;
  1010. {
  1011. X    int i;
  1012. X
  1013. X    for (i=1; i <= nstops; i++)
  1014. X        if (stops[i].line == line && stops[i].file && displayedFile &&
  1015. X            !strcmp(stops[i].file, displayedFile->pathname)) {
  1016. X            return i;
  1017. X        }
  1018. X    return 0;
  1019. }
  1020. X
  1021. void bell(volume)
  1022. int volume;
  1023. {
  1024. X    XBell(XtDisplay(toplevel), volume);
  1025. }
  1026. X
  1027. /* append string s2 to end of string s1 and return the result */
  1028. X
  1029. char *concat(s1, s2)
  1030. char *s1, *s2;
  1031. {
  1032. X    if (s2) {
  1033. X        if (s1 == NULL) {
  1034. X            s1 = XtMalloc((strlen(s2)+1)*sizeof(char));
  1035. X            strcpy(s1, s2);
  1036. X        }
  1037. X        else {
  1038. X            s1 = XtRealloc(s1, strlen(s1)+strlen(s2)+2);
  1039. X            strcat(s1, s2);
  1040. X        }
  1041. X    }
  1042. #if 0    /*(PW)4DEC90 : bug ! if s2 is null, there is no reason to set s1 to 0 */
  1043. X    else
  1044. X        s1 = NULL;
  1045. #endif
  1046. X    return (s1);
  1047. }
  1048. SHAR_EOF
  1049. chmod 0644 mxgdb/utils.c ||
  1050. echo 'restore of mxgdb/utils.c failed'
  1051. Wc_c="`wc -c < 'mxgdb/utils.c'`"
  1052. test 3928 -eq "$Wc_c" ||
  1053.     echo 'mxgdb/utils.c: original size 3928, current size' "$Wc_c"
  1054. rm -f _shar_wnt_.tmp
  1055. fi
  1056. # ============= mxgdb/callgdb.o ==============
  1057. if test -f 'mxgdb/callgdb.o' -a X"$1" != X"-c"; then
  1058.     echo 'x - skipping mxgdb/callgdb.o (File already exists)'
  1059.     rm -f _shar_wnt_.tmp
  1060. else
  1061. > _shar_wnt_.tmp
  1062. echo 'x - extracting mxgdb/callgdb.o (Text)'
  1063. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/callgdb.o' &&
  1064. X`XXXXXXXXXXXXXXXXXXXXdXXXXXXtExtents16UnrealizeWidgetpleRadioBoxXXX)8FV_izX
  1065. SHAR_EOF
  1066. chmod 0644 mxgdb/callgdb.o ||
  1067. echo 'restore of mxgdb/callgdb.o failed'
  1068. Wc_c="`wc -c < 'mxgdb/callgdb.o'`"
  1069. test 32812 -eq "$Wc_c" ||
  1070.     echo 'mxgdb/callgdb.o: original size 32812, current size' "$Wc_c"
  1071. rm -f _shar_wnt_.tmp
  1072. fi
  1073. # ============= mxgdb/gdb.c ==============
  1074. if test -f 'mxgdb/gdb.c' -a X"$1" != X"-c"; then
  1075.     echo 'x - skipping mxgdb/gdb.c (File already exists)'
  1076.     rm -f _shar_wnt_.tmp
  1077. else
  1078. > _shar_wnt_.tmp
  1079. echo 'x - extracting mxgdb/gdb.c (Text)'
  1080. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/gdb.c' &&
  1081. static char rcsid[] = "$Id: gdb.c,v 1.1 1991/08/23 16:34:21 jtsillas Exp $";
  1082. X
  1083. /*****************************************************************************
  1084. X *
  1085. X *  xdbx - X Window System interface to the dbx debugger
  1086. X *
  1087. X *  Copyright 1989 The University of Texas at Austin
  1088. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  1089. X *
  1090. X *  Permission to use, copy, modify, and distribute this software and its
  1091. X *  documentation for any purpose and without fee is hereby granted,
  1092. X *  provided that the above copyright notice appear in all copies and that
  1093. X *  both that copyright notice and this permission notice appear in
  1094. X *  supporting documentation, and that the name of The University of Texas
  1095. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  1096. X *  used in advertising or publicity pertaining to distribution of
  1097. X *  the software without specific, written prior permission.  The
  1098. X *  University of Texas and MCC makes no representations about the 
  1099. X *  suitability of this software for any purpose.  It is provided "as is" 
  1100. X *  without express or implied warranty.
  1101. X *
  1102. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1103. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1104. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  1105. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  1106. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  1107. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  1108. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1109. X *
  1110. X *  Author:      Po Cheung
  1111. X *  Created:       March 10, 1989
  1112. X * 
  1113. X *****************************************************************************
  1114. X * 
  1115. X *  xxgdb - X Window System interface to the gdb debugger
  1116. X *  
  1117. X *     Copyright 1990 Thomson Consumer Electronics, Inc.
  1118. X *  
  1119. X *  Permission to use, copy, modify, and distribute this software and its
  1120. X *  documentation for any purpose and without fee is hereby granted,
  1121. X *  provided that the above copyright notice appear in all copies and that
  1122. X *  both that copyright notice and this permission notice appear in
  1123. X *  supporting documentation, and that the name of Thomson Consumer
  1124. X *  Electronics (TCE) not be used in advertising or publicity pertaining
  1125. X *  to distribution of the software without specific, written prior
  1126. X *  permission.  TCE makes no representations about the suitability of
  1127. X *  this software for any purpose.  It is provided "as is" without express
  1128. X *  or implied warranty.
  1129. X *
  1130. X *  TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1131. X *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  1132. X *  SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  1133. X *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1134. X *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1135. X *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1136. X *  SOFTWARE.
  1137. X *
  1138. X *  Adaptation to GDB:  Pierre Willard
  1139. X *  XXGDB Created:       December, 1990
  1140. X *
  1141. X *****************************************************************************/
  1142. X
  1143. /*
  1144. X *  dbx.c
  1145. X *
  1146. X *    Handle dbx command initialization file (.dbxinit) and communication 
  1147. X *    between dbx and xdbx.
  1148. X *
  1149. X *    dbx_init():    Handle .dbxinit
  1150. X *    debug_init():    
  1151. X *    read_dbx():    Read dbx output, parse and filter it before displaying
  1152. X *            onto the dialog window.
  1153. X *    write_dbx():    Send a command to dbx.
  1154. X *    query_dbx():    Send a command to dbx and process it.
  1155. X */
  1156. X
  1157. #include "global.h"
  1158. X
  1159. Boolean    Prompt;            /* True when dbx prompt arrives */
  1160. char     *concat();
  1161. char    *dbxprompt; 
  1162. char    *xdbxprompt;
  1163. X
  1164. /*  Given a dbx command initialization file, this routine executes each dbx 
  1165. X *  command in the file.  It sends the command to dbx, and calls read_dbx() 
  1166. X *  directly to process output returned from dbx.
  1167. X */
  1168. static void dbx_init(xdbxinit)
  1169. char *xdbxinit;
  1170. {
  1171. X    FILE *fp;
  1172. X    char s[LINESIZ];
  1173. X
  1174. X    if (!strcmp(xdbxinit, ""))
  1175. X    return;
  1176. X    if (fp = fopen(xdbxinit, "r")) {
  1177. X    while (fgets(s, LINESIZ, fp)) {
  1178. X        /* if GDB:
  1179. X            Check for comment line,
  1180. X            DO NOT SEND '\n',
  1181. X            Take care of source command.
  1182. X        */
  1183. X        if ((*s != '#') && strcmp(s,"\n"))
  1184. X          {
  1185. X            if ((!gdb_source_command(s,TRUE)) && 
  1186. X            (!gdb_define_command(s,fp))) 
  1187. X              {
  1188. X            write_dbx(s);
  1189. X            insert_command(s);
  1190. X            AppendDialogText(s);
  1191. X              }
  1192. X        Prompt = False;
  1193. X        while (!Prompt)
  1194. X        read_dbx();
  1195. X        }
  1196. X    }
  1197. X    close((int)fp);
  1198. X    }
  1199. }
  1200. X
  1201. /*
  1202. X *  This routine is called after getting the first dbx prompt.  
  1203. SHAR_EOF
  1204. true || echo 'restore of mxgdb/gdb.c failed'
  1205. fi
  1206. echo 'End of  part 8'
  1207. echo 'File mxgdb/gdb.c is continued in part 9'
  1208. echo 9 > _shar_seq_.tmp
  1209. exit 0
  1210.  
  1211. --
  1212. Dan Heller
  1213. Z-Code Software    O'Reilly && Associates       Comp-sources-x:
  1214. President          Senior Writer                comp-sources-x@uunet.uu.net
  1215. argv@z-code.com    argv@ora.com                 [^^^  this address only!]
  1216.